﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Security.Permissions;

namespace Engine.Dtd {
    /// <summary>
    /// Represents errors that occur during DTD schema parse.
    /// </summary>
    [global::System.Serializable]
    public class DtdException : Exception {
        /// <summary>
        /// Initialize a new instance of the DtdException class.
        /// </summary>
        public DtdException() { }
        /// <summary>
        /// Initialize a new instance of the DtdException class with a specified error message.
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        public DtdException(string message) : base(message) { }
        /// <summary>
        /// Initialize a new instance of the DtdException class with a specified error message and context.
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        /// <param name="context">The string containing information about current error situation.</param>
        public DtdException(string message, string context)
            : base(message) {
            Context = context;
            }
        /// <summary>
        /// Initialize a new instance of the DtdException class with a specified error message and a reference to the inner exception
        /// that is the cause of this exception.
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        /// <param name="inner">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
        public DtdException(string message, Exception inner) : base(message, inner) { }

        /// <summary>
        /// Initialize a new instance of the DtdException class with serialization data.
        /// </summary>
        /// <param name="info">The System.Runtime.Serialization.SerializationInfo that holds the serialized object data about the exception being thrown.</param>
        /// <param name="context">The System.Runtime.Serialization.StreamingContext that contains contextual information about the source or destination.</param>
        protected DtdException(
          System.Runtime.Serialization.SerializationInfo info,
          System.Runtime.Serialization.StreamingContext context)
            : base(info, context) { }

        /// <summary>
        /// Sets the System.Runtime.Serialization.SerializationInfo with information about the exception.
        /// </summary>
        /// <param name="info">
        /// The System.Runtime.Serialization.SerializationInfo that holds the serialized
        /// object data about the exception being thrown.
        /// </param>
        /// <param name="context">
        /// The System.Runtime.Serialization.StreamingContext that contains contextual
        /// information about the source or destination.
        /// </param>
        [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
        public override void GetObjectData(SerializationInfo info, StreamingContext context) {
            base.GetObjectData(info, context);
            }

        /// <summary>
        /// Returns an information about current error situation.
        /// </summary>
        public string Context { get; private set; }
        }
    }
